package com.facebook.imagepipeline.producers;

import com.facebook.cache.common.CacheKey;
import com.facebook.common.internal.ImmutableMap;
import com.facebook.common.internal.VisibleForTesting;
import com.facebook.common.references.CloseableReference;
import com.facebook.imagepipeline.cache.CacheKeyFactory;
import com.facebook.imagepipeline.cache.MemoryCache;
import com.facebook.imagepipeline.image.CloseableImage;
import com.facebook.imagepipeline.image.QualityInfo;
import com.facebook.imagepipeline.request.ImageRequest;
import com.facebook.imagepipeline.request.ImageRequest.RequestLevel;
import java.util.Map;

public class BitmapMemoryCacheProducer
  implements Producer<CloseableReference<CloseableImage>>
{

  @VisibleForTesting
  static final String PRODUCER_NAME = "BitmapMemoryCacheProducer";

  @VisibleForTesting
  static final String VALUE_FOUND = "cached_value_found";
  private final CacheKeyFactory mCacheKeyFactory;
  private final Producer<CloseableReference<CloseableImage>> mInputProducer;
  private final MemoryCache<CacheKey, CloseableImage> mMemoryCache;

  public BitmapMemoryCacheProducer(MemoryCache<CacheKey, CloseableImage> paramMemoryCache, CacheKeyFactory paramCacheKeyFactory, Producer<CloseableReference<CloseableImage>> paramProducer)
  {
    this.mMemoryCache = paramMemoryCache;
    this.mCacheKeyFactory = paramCacheKeyFactory;
    this.mInputProducer = paramProducer;
  }

  protected String getProducerName()
  {
    return "BitmapMemoryCacheProducer";
  }

  public void produceResults(Consumer<CloseableReference<CloseableImage>> paramConsumer, ProducerContext paramProducerContext)
  {
    ProducerListener localProducerListener = paramProducerContext.getListener();
    String str1 = paramProducerContext.getId();
    localProducerListener.onProducerStart(str1, getProducerName());
    ImageRequest localImageRequest = paramProducerContext.getImageRequest();
    Object localObject = paramProducerContext.getCallerContext();
    CacheKey localCacheKey = this.mCacheKeyFactory.getBitmapCacheKey(localImageRequest, localObject);
    CloseableReference localCloseableReference = this.mMemoryCache.get(localCacheKey);
    if (localCloseableReference != null)
    {
      boolean bool2 = ((CloseableImage)localCloseableReference.get()).getQualityInfo().isOfFullQuality();
      String str4;
      if (bool2)
      {
        str4 = getProducerName();
        if (!localProducerListener.requiresExtraMap(str1))
          break label165;
      }
      label165: for (Map localMap3 = ImmutableMap.of("cached_value_found", "true"); ; localMap3 = null)
      {
        localProducerListener.onProducerFinishWithSuccess(str1, str4, localMap3);
        paramConsumer.onProgressUpdate(1.0F);
        paramConsumer.onNewResult(localCloseableReference, bool2);
        localCloseableReference.close();
        if (!bool2)
          break;
        return;
      }
    }
    if (paramProducerContext.getLowestPermittedRequestLevel().getValue() >= ImageRequest.RequestLevel.BITMAP_MEMORY_CACHE.getValue())
    {
      String str3 = getProducerName();
      if (localProducerListener.requiresExtraMap(str1));
      for (Map localMap2 = ImmutableMap.of("cached_value_found", "false"); ; localMap2 = null)
      {
        localProducerListener.onProducerFinishWithSuccess(str1, str3, localMap2);
        paramConsumer.onNewResult(null, true);
        return;
      }
    }
    Consumer localConsumer = wrapConsumer(paramConsumer, localCacheKey);
    String str2 = getProducerName();
    boolean bool1 = localProducerListener.requiresExtraMap(str1);
    Map localMap1 = null;
    if (bool1)
      localMap1 = ImmutableMap.of("cached_value_found", "false");
    localProducerListener.onProducerFinishWithSuccess(str1, str2, localMap1);
    this.mInputProducer.produceResults(localConsumer, paramProducerContext);
  }

  protected Consumer<CloseableReference<CloseableImage>> wrapConsumer(Consumer<CloseableReference<CloseableImage>> paramConsumer, final CacheKey paramCacheKey)
  {
    return new DelegatingConsumer(paramConsumer)
    {
      // ERROR //
      public void onNewResultImpl(CloseableReference<CloseableImage> paramAnonymousCloseableReference, boolean paramAnonymousBoolean)
      {
        // Byte code:
        //   0: aload_1
        //   1: ifnonnull +19 -> 20
        //   4: iload_2
        //   5: ifeq +14 -> 19
        //   8: aload_0
        //   9: invokevirtual 29	com/facebook/imagepipeline/producers/BitmapMemoryCacheProducer$1:getConsumer	()Lcom/facebook/imagepipeline/producers/Consumer;
        //   12: aconst_null
        //   13: iconst_1
        //   14: invokeinterface 35 3 0
        //   19: return
        //   20: aload_1
        //   21: invokevirtual 41	com/facebook/common/references/CloseableReference:get	()Ljava/lang/Object;
        //   24: checkcast 43	com/facebook/imagepipeline/image/CloseableImage
        //   27: invokevirtual 47	com/facebook/imagepipeline/image/CloseableImage:isStateful	()Z
        //   30: ifeq +15 -> 45
        //   33: aload_0
        //   34: invokevirtual 29	com/facebook/imagepipeline/producers/BitmapMemoryCacheProducer$1:getConsumer	()Lcom/facebook/imagepipeline/producers/Consumer;
        //   37: aload_1
        //   38: iload_2
        //   39: invokeinterface 35 3 0
        //   44: return
        //   45: iload_2
        //   46: ifne +101 -> 147
        //   49: aload_0
        //   50: getfield 18	com/facebook/imagepipeline/producers/BitmapMemoryCacheProducer$1:this$0	Lcom/facebook/imagepipeline/producers/BitmapMemoryCacheProducer;
        //   53: invokestatic 51	com/facebook/imagepipeline/producers/BitmapMemoryCacheProducer:access$000	(Lcom/facebook/imagepipeline/producers/BitmapMemoryCacheProducer;)Lcom/facebook/imagepipeline/cache/MemoryCache;
        //   56: aload_0
        //   57: getfield 20	com/facebook/imagepipeline/producers/BitmapMemoryCacheProducer$1:val$cacheKey	Lcom/facebook/cache/common/CacheKey;
        //   60: invokeinterface 56 2 0
        //   65: astore 6
        //   67: aload 6
        //   69: ifnull +78 -> 147
        //   72: aload_1
        //   73: invokevirtual 41	com/facebook/common/references/CloseableReference:get	()Ljava/lang/Object;
        //   76: checkcast 43	com/facebook/imagepipeline/image/CloseableImage
        //   79: invokevirtual 60	com/facebook/imagepipeline/image/CloseableImage:getQualityInfo	()Lcom/facebook/imagepipeline/image/QualityInfo;
        //   82: astore 8
        //   84: aload 6
        //   86: invokevirtual 41	com/facebook/common/references/CloseableReference:get	()Ljava/lang/Object;
        //   89: checkcast 43	com/facebook/imagepipeline/image/CloseableImage
        //   92: invokevirtual 60	com/facebook/imagepipeline/image/CloseableImage:getQualityInfo	()Lcom/facebook/imagepipeline/image/QualityInfo;
        //   95: astore 9
        //   97: aload 9
        //   99: invokeinterface 65 1 0
        //   104: ifne +20 -> 124
        //   107: aload 9
        //   109: invokeinterface 69 1 0
        //   114: aload 8
        //   116: invokeinterface 69 1 0
        //   121: if_icmplt +21 -> 142
        //   124: aload_0
        //   125: invokevirtual 29	com/facebook/imagepipeline/producers/BitmapMemoryCacheProducer$1:getConsumer	()Lcom/facebook/imagepipeline/producers/Consumer;
        //   128: aload 6
        //   130: iconst_0
        //   131: invokeinterface 35 3 0
        //   136: aload 6
        //   138: invokestatic 73	com/facebook/common/references/CloseableReference:closeSafely	(Lcom/facebook/common/references/CloseableReference;)V
        //   141: return
        //   142: aload 6
        //   144: invokestatic 73	com/facebook/common/references/CloseableReference:closeSafely	(Lcom/facebook/common/references/CloseableReference;)V
        //   147: aload_0
        //   148: getfield 18	com/facebook/imagepipeline/producers/BitmapMemoryCacheProducer$1:this$0	Lcom/facebook/imagepipeline/producers/BitmapMemoryCacheProducer;
        //   151: invokestatic 51	com/facebook/imagepipeline/producers/BitmapMemoryCacheProducer:access$000	(Lcom/facebook/imagepipeline/producers/BitmapMemoryCacheProducer;)Lcom/facebook/imagepipeline/cache/MemoryCache;
        //   154: aload_0
        //   155: getfield 20	com/facebook/imagepipeline/producers/BitmapMemoryCacheProducer$1:val$cacheKey	Lcom/facebook/cache/common/CacheKey;
        //   158: aload_1
        //   159: invokeinterface 77 3 0
        //   164: astore_3
        //   165: iload_2
        //   166: ifeq +13 -> 179
        //   169: aload_0
        //   170: invokevirtual 29	com/facebook/imagepipeline/producers/BitmapMemoryCacheProducer$1:getConsumer	()Lcom/facebook/imagepipeline/producers/Consumer;
        //   173: fconst_1
        //   174: invokeinterface 81 2 0
        //   179: aload_0
        //   180: invokevirtual 29	com/facebook/imagepipeline/producers/BitmapMemoryCacheProducer$1:getConsumer	()Lcom/facebook/imagepipeline/producers/Consumer;
        //   183: astore 5
        //   185: aload_3
        //   186: ifnull +5 -> 191
        //   189: aload_3
        //   190: astore_1
        //   191: aload 5
        //   193: aload_1
        //   194: iload_2
        //   195: invokeinterface 35 3 0
        //   200: aload_3
        //   201: invokestatic 73	com/facebook/common/references/CloseableReference:closeSafely	(Lcom/facebook/common/references/CloseableReference;)V
        //   204: return
        //   205: astore 7
        //   207: aload 6
        //   209: invokestatic 73	com/facebook/common/references/CloseableReference:closeSafely	(Lcom/facebook/common/references/CloseableReference;)V
        //   212: aload 7
        //   214: athrow
        //   215: astore 4
        //   217: aload_3
        //   218: invokestatic 73	com/facebook/common/references/CloseableReference:closeSafely	(Lcom/facebook/common/references/CloseableReference;)V
        //   221: aload 4
        //   223: athrow
        //
        // Exception table:
        //   from	to	target	type
        //   72	124	205	finally
        //   124	136	205	finally
        //   169	179	215	finally
        //   179	185	215	finally
        //   191	200	215	finally
      }
    };
  }
}

/* Location:           C:\Users\user\Desktop\dd28_pcdd720\classes_dex2jar.jar
 * Qualified Name:     com.facebook.imagepipeline.producers.BitmapMemoryCacheProducer
 * JD-Core Version:    0.6.2
 */